<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>zakinit</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="zacl.html" title="zacl" />
    <link rel="next" href="zamod.html" title="zamod" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">zakinit</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="zacl.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="zamod.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="zakinit"></a>
      <div class="titlepage"></div>
      <a id="IndexZakinit" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">zakinit</span>
        </h2>
        <p>zakinit — 
      Establishes zak space.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp169453936"></a>
        <h2>Description</h2>
        <p>
      Establishes zak space. Must be called only once.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169455232"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>zakinit</strong></span> isizea, isizek</pre>
      </div>
      <div class="refsect1">
        <a id="idp169457312"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>isizea</em></span> -- the number of audio rate locations for a-rate patching. Each location is actually an array which is ksmps long.
    </p>
        <p>
      <span class="emphasis"><em>isizek</em></span> -- the number of locations to reserve for floats in the zk space. These can be written and read at i- and k-rates.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169460288"></a>
        <h2>Performance</h2>
        <p>
      At least one location each is always allocated for both za and zk spaces. There can be thousands or tens of thousands za and zk ranges, but most pieces probably only need a few dozen for patching signals. These patching locations are referred to by number in the other zak opcodes.
    </p>
        <p>
      To run <span class="emphasis"><em>zakinit</em></span> only once, put it outside any instrument definition, in the orchestra file header, after <span class="emphasis"><em>sr</em></span>, <span class="emphasis"><em>kr</em></span>, <span class="emphasis"><em>ksmps</em></span>, and <span class="emphasis"><em>nchnls</em></span>.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        Zak channels count from 0, so if you define 1 channel, the only valid channel is channel 0.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp169465744"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the zakinit opcode. It uses the file <a class="ulink" href="examples/zakinit.csd" target="_top"><em class="citetitle">zakinit.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp169467520"></a>
          <p class="title">
            <strong>Example 1062. Example of the zakinit opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o zakinit.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 4410
<span class="ohdr">nchnls</span> <span class="op">=</span> 1

<span class="comment">; Initialize the ZAK space.</span>
<span class="comment">; Create 3 a-rate variables and 5 k-rate variables.</span>
<span class="opc">zakinit</span> 2, 3

<span class="oblock">instr</span> 1 <span class="comment">;a simple waveform.</span>
	<span class="comment">; Generate a simple sine waveform.</span>
	asin <span class="opc">oscil</span> 20000, 440, 1

	<span class="comment">; Send the sine waveform to za variable #1.</span>
	<span class="opc">zaw</span> asin, 1
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2  <span class="comment">;generates audio output.</span>
	<span class="comment">; Read za variable #1.</span>
	a1 <span class="opc">zar</span> 1

	<span class="comment">; Generate audio output.</span>
	<span class="opc">out</span> a1

	<span class="comment">; Clear the za variables, get them ready for </span>
	<span class="comment">; another pass.</span>
	<span class="opc">zacl</span> 0, 3
<span class="oblock">endin</span>

<span class="oblock">instr</span> 3  <span class="comment">;increments k-type channels</span>
	k0 <span class="opc">zkr</span> 0
	k1 <span class="opc">zkr</span> 1
	k2 <span class="opc">zkr</span> 2

	<span class="opc">zkw</span> k0<span class="op">+</span>1, 0
	<span class="opc">zkw</span> k1<span class="op">+</span>5, 1
	<span class="opc">zkw</span> k2<span class="op">+</span>10, 2
<span class="oblock">endin</span>

<span class="oblock">instr</span> 4 <span class="comment">;displays values from k-type channels</span>
	k0 <span class="opc">zkr</span> 0
	k1 <span class="opc">zkr</span> 1
	k2 <span class="opc">zkr</span> 2

<span class="comment">; The total count for k0 is 30, since there are 10</span>
<span class="comment">; control blocks per second and intruments 3 and 4</span>
<span class="comment">; are on for 3 seconds.</span>
	<span class="opc">printf</span> "k0 <span class="op">=</span> <span class="op">%</span>i\n",k0, k0
	<span class="opc">printf</span> "k1 <span class="op">=</span> <span class="op">%</span>i\n",k1, k1
	<span class="opc">printf</span> "k2 <span class="op">=</span> <span class="op">%</span>i\n",k2, k2
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; Table #1, a sine wave.</span>
<span class="stamnt">f</span> 1 0 16384 10 1

<span class="stamnt">i</span> 1 0 1
<span class="stamnt">i</span> 2 0 1

<span class="stamnt">i</span> 3 0 3
<span class="stamnt">i</span> 4 0 3
<span class="stamnt">e</span>

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169471744"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Robin Whittle</td>
          </tr>
          <tr>
            <td>Australia</td>
          </tr>
          <tr>
            <td>May 1997</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 3.45</p>
        <p>Example written by Kevin Conder.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="zacl.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="zamod.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">zacl </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> zamod</td>
        </tr>
      </table>
    </div>
  </body>
</html>
